<meta charset="utf-8">
<div th:fragment="navbar">
	<div class="ui fixed inverted menu" id="headerMain" style="background:#4F94CD">
	    <a th:href="@{/}" class="header item">
	        <img class="ui" th:src="@{/img/logo.png}" width="156" height="32" alt="" />
	    </a>
	    <a th:href="@{/exam/examination}" class="item" th:class="${activeUri=='examiantion'?'item active':'item'}">
	        <i class="desktop icon"></i>在线考试
	    </a>
	    <a th:href="@{/exam/questions}" class="item" th:class="${activeUri=='question'?'item active':'item'}">
	        <i class="list layout icon"></i>题库中心
	    </a>
	    <a th:href="@{/exam/queryScore}" class="item" th:class="${activeUri=='score'?'item active':'item'}">
	        <i class="paper plane icon"></i>成绩查询
	    </a>
	    <a th:href="@{/exam/comment}" class="item" th:class="${activeUri=='comment'?'item active':'item'}">
	        <i class="talk icon"></i>留言板
	    </a>
	    <shiro:notAuthenticated>
		    <a id="login" href="/login" class="right item">
		        <i class="sign in icon"></i>登录
		    </a>
	    </shiro:notAuthenticated>
	    <shiro:authenticated>
		    <div class="ui simple dropdown right item">
		        <img class="ui avatar image" id="imgSrc"/>
		        <span id="userImg" style="display: none"><shiro:principal property="img" /></span>
		        <span><shiro:principal property="nickname"/></span><i class="dropdown icon"></i>
		        <div class="menu">
		        	<shiro:hasPermission name="manager">
		        		<a class="item" href="/manager" target="view_window">
		                	<i class="laptop icon"></i>进入管理后台
		            	</a>
		        	</shiro:hasPermission>
		            <a class="item" id="myInfo">
		                <i class="edit icon"></i>编辑个人资料
		            </a>
		            <a class="item" id="logoutBtn">
		                <i class="sign out icon"></i>退出
		            </a>
		        </div>
		    </div>
	    </shiro:authenticated>
	</div>
	<script type="text/javascript">
		$("#imgSrc").attr("src",$("#userImg").text());
		$(function(){
			/* 退出 */
			$("#logoutBtn").on('click',function(){
				Core.confirm("确定退出?", function(){
					Core.postAjax("/logout", {}, function(data){
						if(data.status==200){
							window.location.href="/login";
						}else{
							layer.msg(data.msg);
						}
					})
				})
			})
			/* 我的信息 */
			$("#myInfo").on('click', function(){
				window.location.href="/exam/personInfo";
			})
		});
	</script>
</div>
